{include file="Public/header" /}
<style>
	label{
	  color: #000;
	}
</style>
<form method="post" class="form-x" action="{if $data.id}?id={$data.id}{/if}" style="color: #000;background: #fff">
	<div class="panel admin-panel">
		<div class="panel-head"></div>
		<br/>
		<div class="form-group">
			<div class="label">
			       <label for="type">{:lang('label')['type']}</label>
			</div>
			<div class="field">
				<select class="input input-auto" id="type" name="type">
					<option>请选择</option>
					{if input('session.type') == 'all'}
					<option {if $data.type =='all'} selected {/if} value="all">总管理</option>
					{/if}
					{if input('session.type') == 'province' || input('session.type') == 'all'}
					<option {if $data.type == 'province'} selected {/if} value="province">省管理</option>
					{/if}
					{if input('session.type') == 'province' ||  input('session.type') == 'city' || input('session.type') == 'all'}
					<option {if $data.type == 'city'} selected {/if} value="city">市管理</option>
					{/if}
					<option {if $data.type == 'area'} selected {/if} value="area">县管理</option>
				</select>
			</div>
		</div>
		<div id="province_box" name="box" class="form-group {if $data.type != 'province'}hidden{/if}">
			<div class="label">
				<label>省</label>
			</div>
			<div class="field">
				<ul class="list-inline" style="max-height: 200px; overflow: auto">
					{volist name="province" id="province_list"}
					<li><input id="{$province_list.id}" {if $data['aid'] == $province_list.id}checked{/if} name="aid" type="radio" value="{$province_list.id}" /><label for="{$province_list.id}">{$province_list.name}</label></input></li>
					{/volist}
				</ul>
			</div>
		</div>
		<div id="city_box" name="box" class="form-group {if $data.type != 'city'}hidden{/if}">
			<div class="label">
				<label>市</label>
			</div>
			<div class="field">
				<ul class="list-inline" style="max-height: 200px; overflow: auto">
					{volist name="city" id="city_list"}
					<li><input id="{$city_list.id}" {if $data['aid'] == $city_list.id}checked{/if} name="aid" type="radio" value="{$city_list.id}" /><label for="{$city_list.id}">{$city_list.name}</label></input></li>
					{/volist}
				</ul>
			</div>
		</div>
		<div id="area_box" name="box" class="form-group {if $data.type != 'area'}hidden{/if}">
			<div class="label">
				<label>县</label>
			</div>
			<div class="field">
				<ul class="list-inline" style="max-height: 200px; overflow: auto">
					{volist name="area" id="area_list"}
					<li><input id="{$area_list.id}" {if $data['aid'] == $area_list.id}checked{/if} name="aid" type="radio" value="{$area_list.id}" /><label for="{$area_list.id}">{$area_list.name}</label></input></li>
					{/volist}
				</ul>
			</div>
		</div>

		<div class="form-group">
			<div class="label">
				<label for="username">{:lang('label')['username']}</label>
			</div>
			<div class="field">
				<input type="text" class="input input-auto" id="username" name="username" value="{$data.username}" size="80" placeholder="{:lang('label')['username']}" data-validate="required:{:lang('currency')['required']}" />
			</div>
		</div>
		<div class="form-group">
			<div class="label">
				<label for="phone">{:lang('label')['phone']}</label>
			</div>
			<div class="field">
				<input type="text" class="input input-auto" id="phone" name="phone" value="{$data.phone}" size="80" placeholder="{:lang('label')['phone']}" data-validate="required:{:lang('currency')['required']}" />
			</div>
		</div>
		<div class="form-group">
			<div class="label">
				<label for="password">{:lang('label')['password']}</label>
			</div>
			<div class="field">
				<input type="text" class="input input-auto" id="password" name="password" value="" size="80" placeholder="{:lang('label')['password']}" {if !$data.id}data-validate="required:{:lang('currency')['required']}"{/if} />
			</div>
		</div>
		<div class="form-group">
			<input class="hidden" name="auth"/><!--占位-->
			<div class="input-inline clearfix">
				<div class="label">
				        <label>{:lang('label')['auth']}</label>
				</div>
				{php}$session_auth =explode(',',input('session.auth'));$autharray = explode(',',$data['auth']);{/php}
				<div class="field">
					<ul class="list-inline">
						{if input('session.type') == 'all'}
							{volist name="menu_all" id="volist"}
							<li {if $i==0}class="active"{/if} style="width: 100%">
								<input data-order="{$i}" id="check{$i}" class="check" {if in_array($volist.auth,$autharray)}checked{/if} name="auth[]" type="checkbox" value="{$volist.auth}" /><label for="check{$i}">{$volist.name}</label>
								<ul class="list-inline">
									{volist name="volist.sub" key="j" id="sublist"}
									<li>
										<input id="check{$i}{$j}" class="checksub checksub{$i}" {if in_array($sublist.auth,$autharray)}checked{/if} name="auth[]" type="checkbox" value="{$sublist.auth}" /><label for="check{$i}{$j}">{$sublist.name}</label>
									</li>
									{/volist}
								</ul>
							</li>
							{/volist}
						{else}
							{volist name="menu_all" id="volist"}
							        {if in_array($volist.auth,$session_auth)}
							        <li {if $i==0}class="active"{/if} style="width: 100%">
									<input data-order="{$i}" id="check{$i}" class="check" {if in_array($volist.auth,$autharray)}checked{/if} name="auth[]" type="checkbox" value="{$volist.auth}" /><label for="check{$i}">{$volist.name}</label>
									<ul class="list-inline">
										{volist name="volist.sub" key="j" id="sublist"}
											{if in_array($sublist.auth,$session_auth)}
											<li>
												<input id="check{$i}{$j}" class="checksub checksub{$i}" {if in_array($sublist.auth,$autharray)}checked{/if} name="auth[]" type="checkbox" value="{$sublist.auth}" /><label for="check{$i}{$j}">{$sublist.name}</label>
											</li>
											{/if}
										{/volist}
									</ul>
								</li>
								{/if}
							{/volist}
						{/if}
					</ul>
				</div>
			</div>
		</div>
		<div class="form-button">
			<button class="button bg-main submit" type="button">{:lang('form')['submit']}</button>
			<button class="button bg-main hidden truesubmit" type="submit"></button>
		</div>
		<br/>
	</div>
</form>
<script>
	/*$("#type").click(function(){
	 var type = $("#type").val();
	 if(type=='1'){
	 $("#city").addClass('hidden');
	 }else{
	 $("#city").removeClass('hidden');
	 }
	 });*/
    $("#type").change(function (){
        var type = $("#type").val();
        if(type == 'all'){
            $("div[name=box]").attr('class','form-group hidden');
        }else{
            $("div[name=box]").attr('class','form-group hidden');
            $('#'+type+'_box').attr('class','form-group');
        }
    });
    $(".check").click(function(){
        $(".checksub"+$(this).attr('data-order')).prop("checked",$(this).prop("checked"));
    });
    $(".checksub").click(function(){
        if(!$(this).parent().parent().parent().find('input').prop("checked")){
            //alert("{:lang('currency')['authtip']}");
             msg("{:lang('currency')['authtip']}");
            return false;
        }
    });
 $(".submit").click(function(){
       if($("#check11").is(":checked")){
	      $('.truesubmit').click();
	     }else{
		msg('请选择首页权限');
	     }
    });
</script>
{include file="Public/footer" /}